#include <stdio.h>

int main(int argc, char ** argv)
{
    //stdin键盘
    //stdout stderr 终端文件
#if 0
    char buffer[1024] = {0};
    fgets(buffer, 1024, stdin); //从键盘获取数据
    fputs(buffer, stdout);      //从终端输出

    fputs("open file error", stdout);   //stdout stderr有无缓冲区的区别

#endif
    FILE *fp = fopen(argv[1], "w+");
    fprintf(fp, "name = %s  num = %d  age = %d\n", "zhangsan", 1, 12);      //写入fp文件
    char name[100];
    int num;
    int age;
    rewind(fp);
    fscanf(fp, "name = %s  num = %d  age = %d\n", name, &num, &age);        //从fp文件读取
    printf("name = %s  num = %d  age = %d\n", name, num, age);              //打印fp文件
    fflush(stdout);                     //刷新
    //while(1);

    return 0;
}